<template>
	<view class="list">
		<mescroll-body @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
			<view class="item" v-for="(item,index) in list_data" :key="index" :class="{'item-last': list_data && index === list_data.length - 1}">
				<view class="item_left">
					<text class="item_1">用户{{item.uid}}{{item.trade_type == 1?"买积分":"开会员"}}</text>
					<text class="item_2">{{item.create_time}}</text>
				</view>
				<view class="item_right">
					<text class="item_3">+{{item.invite_amount}}（{{item.amount}}）</text>
				</view>
			</view>
		</mescroll-body>
	</view>
</template>

<script>
	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
	import {
		get_daili_xiaji_pay_list
	} from '@/src/api/huanlian.js'
	export default {
		mixins: [MescrollMixin], // 使用mixin
		data() {
			return {
				list_data: null,
				downOption: {},
				// 上拉加载的配置(可选, 绝大部分情况无需配置)
				upOption: {
					page: {
						size: 10 // 每页数据的数量,默认10
					},
					noMoreSize: 5, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
					empty: {
						tip: '暂无相关数据'
					}
				},
				date:null
			}
		},
		onLoad(optinos) {
			this.date = optinos.date
		},
		methods: {
			async upCallback(page) {
				try {
					let res = await get_daili_xiaji_pay_list({
						page_number: page.num,
						date:this.date
					})
					let curPageData = res.data.list
					let curPageLen = curPageData.length;
					if (page.num == 1) this.list_data = []; //如果是第一页需手动置空列表
					this.list_data = this.list_data.concat(curPageData); //追加新数据
					setTimeout(() => {
						this.mescroll.endSuccess(curPageLen, res.data.has_next);
					}, 500)
				} catch (e) {
					this.mescroll.endErr()
					if (!e) return
					uni.showModal({
						content: e.errMsg || e.message,
						showCancel: false
					});
				}
			},
		}
	}
</script>

<style lang="scss">
	@import 'DaiLiXiaJiPay.scss';
</style>
